package com.java.base.exercise.jvm;

/**
 * @Author RenPu
 * @Date 2021/10/11 17:37
 * @Version 1.0
 * @Description: GC回收算法   引用计数算法的缺陷
 **/
public class ReferenceCountingGC {
    public Object instance = null;
    private static final int _1MB = 1024 * 1024;

    //此处用意，占点内存便于在GC日志中看清楚是否被回收
    byte[] bigSize = new byte[2 * _1MB];

    public static void main(String[] args) {
        ReferenceCountingGC objA = new ReferenceCountingGC();
        ReferenceCountingGC objB = new ReferenceCountingGC();
        objA.instance = objB;
        objB.instance = objA;
        objA = null;
        objB = null;
        System.gc();

    }


}
